//
//  JTProvisionViewController.m
//  JiongTu
//
//  Created by 杨璟 on 16/3/29.
//  Copyright © 2016年 YSKJ. All rights reserved.
//

#import "JTProvisionViewController.h"

@interface JTProvisionViewController ()

@property (weak, nonatomic) IBOutlet UIWebView *provisionWebView;

@end

@implementation JTProvisionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //如果导航控制器含有其他控制器，则是被push出来
    NSArray *viewcontrollers=self.navigationController.viewControllers;
    if (viewcontrollers.count>1) {
        if ([viewcontrollers objectAtIndex:viewcontrollers.count-1]==self) {
            self.navigationItem.title = @"法律条款";
            self.navigationItem.rightBarButtonItem = nil;
        }
    //反之没有其他控制器则是被pop出来
    } else {
        self.navigationItem.title = @"拼车条款";
    }
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
    NSArray *viewcontrollers=self.navigationController.viewControllers;
    if (viewcontrollers.count>1) {
        if ([viewcontrollers objectAtIndex:viewcontrollers.count-1]==self) {
            //push方式
            NSString *filePath = [[NSBundle mainBundle]pathForResource:@"Law" ofType:@"html"];
            NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
            [self.provisionWebView loadHTMLString:htmlString baseURL:[NSURL URLWithString:filePath]];
        }
    } else {
        //present方式
        NSString *filePath = [[NSBundle mainBundle]pathForResource:self.provisionName ofType:@"html"];
        NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
        [self.provisionWebView loadHTMLString:htmlString baseURL:[NSURL URLWithString:filePath]];
        
    }
}

- (IBAction)dismissClick:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
